Repository navigation
Ship real type declarations for botframework-directlinespeech-sdk - #6037
Eugene (OEvgeny) wants to merge 5 commits into
Conversation
|
We should add tests with tsd like core and bundle do |
| "require": { | ||
| "types": "./lib/index.d.ts", | ||
| "types": "./dist/botframework-directlinespeech-sdk.d.ts", | ||
| "default": "./lib/index.js" |
There was a problem hiding this comment.
Should we move to tsup to build instead of Webpack?
How are we doing on bundle package?
There was a problem hiding this comment.
Yes, I think we should. A quick trial with one tsup config (ESM, CommonJS and the two IIFE browser scripts) replaced both Babel (lib/) and Webpack here: the browser scripts built in under a second, kept the same window.DirectLineSpeech exports, and the production one went from 613 KB to 500 KB. The catch is that require users would move from Babel's lib/ to tsup's CommonJS file, so it needs a real Direct Line Speech run before it ships. I'd rather keep this PR to the types and do that as the next one. It also lines this package up with the others for the tsdown move.
bundle already builds without Webpack (tsup, plus esbuild for static/) since #5329. Webpack is still used by directlinespeech, embed and the two isomorphic-react* packages.
|
Added tsd tests in |
Changelog Entry
Fixed
botframework-directlinespeech-sdkshipping JavaScript as type declarations, and thecreateDirectLineSpeechAdaptersreturn type namingwebSpeechPonyfillinstead ofwebSpeechPonyfillFactory, in PR #6037, by @OEvgenyDescription
tsup emitted the bundled JavaScript as the package's
.d.mts/.d.ts, and therequiretypes pointed to a never-builtlib/index.d.ts: TypeScript consumers got wrong types (ESM) or none (CommonJS). The package now ships hand-written declarations for both. The bundle'screateDirectLineSpeechAdapterstype returnswebSpeechPonyfillFactory, as at runtime, notwebSpeechPonyfill.Design
index.d.tsrather than converting to TypeScript (1,700 lines) or generating from JSDoc (there is none, so allany)..d.mtsand.d.ts: onesrc/index.d.tsfor both conditions makes ESM types "masquerade as CJS" (arethetypeswrong).as any:web-speech-cognitive-services'SpeechRecognitionis not assignable totypeof SpeechRecognition.Specific Changes
directlinespeech/src/index.d.ts: declarations forcreateAdaptersandbuildInfo; activities typed as interfaces are accepteddirectlinespeech/tsup.config.ts: emits themdirectlinespeech/package.json:requireand top-leveltypespoint todist/*.d.tsdirectlinespeech/test-d/: tsd tests of the shipped declarations (options, result,buildInfo, invalid options), run by the "Type definitions test" jobbundle/src/createDirectLineSpeechAdapters.ts:webSpeechPonyfillFactoryin the return typebundle/test-d/pass/create-direct-line-speech-adapters.test-d.ts: checks itI have added tests and executed them locally
I have added
.changelog/<PR#>-<slug>.mdI have updated documentation
Review Checklist
z-index)package.jsonandpackage-lock.jsonreviewed