-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Closed
Labels
Design NotesNotes from our design meetingsNotes from our design meetings
Description
Libraries Patching TypeScript's API
https://gist.github.com/jakebailey/3e73c7aab4da2044a95121467aa3b4e9
- In TypeScript 5.0, libraries can no longer override properties of our API.
- Language service plugins
- typescript-plugin-css-modules
- Can no longer patch
createLanguageServiceSourceFileandupdateLanguageServiceSourceFile - Make ones up with CSS.
- Should be proxying the language service host
- Can no longer patch
- vuejs/language-tools
- Same deal with
resolveModuleName- The new 5.0 resolution modes are better fits.
--moduleResolution bundler--allowArbitraryExtensions- Use
.d.vue.tsfiles.
- Use
- The new 5.0 resolution modes are better fits.
- There's really no host-level function they can override? Surprising.
- Seems like no?
- But resolveModuleName takes a
ModuleResolutionHost- is there a way to control that?- Seems fairly file-system-oriented.
- Actually some hosts do have a
resolveModuleNamesproxyPluginHostshould sethost.resolveModuleNameLiterals.
- Still, using the new resolution modes is recommended, but if they're determined to support node16/nodenext (they shouldn't, we don't believe it's actually the the right thing to use), patching
resolveModuleNameLiteralsis the right thing. - Meta: they recommend most users use this instead of our language server: https://vuejs.org/guide/typescript/overview.html#volar-takeover-mode
- Same deal with
- typescript-plugin-css-modules
- Supporting Transformers
- ttypescript
createProgram
- ts-patch
createProgram, lots of other top-level stuff to enable caching.
- The core idea is that these packages don't want to support all of the tsc command line and whatnot.
- Is
executeCommandLinepublic?- Yes. (later: no)
- Then they should be using that.
- Ehh, it's not exported.
- Only internally exported for testing scenarios.
- Also there's no emit hook. Can't plug transforms in today.
program.emitis overridable fromexecuteCommandLine- But that happens after emit occurs.
- But you can set
noEmitand then force emit. - But then you don't get declaration file diagnostics.
- Come back to these.
- ttypescript
- Stencil - has its own compiler
- Sets
ts.sys - We have an
/* @internal */ function setSysthat they can use. - Also use
resolveModuleName- they should be passing this into theCompilerHostthey create - So actually, most of this should be on the
CompilerHost - There are some functions they patch which we missed.
- Sets
- Heft
- Build system that wraps TypeScript.
readJson- only reason for this is caching.emitFiles- patched so that they can support multiple emit targets.- Possible idea: you have the
CompilerHost, just patch it every time and re-run emit.- Tried, but was unsuccessful.
- Yarn
- Still works! Patched in a different way, maintained in a fork.
- Would like to make this easier, but not in near-term range.
Comparing Wrapper Objects
1is anumberNumber(1)is anumbernew Number(1)is aNumber- a wrapper object.- All numeric and relational operations turn the wrapper objects back into their primitive equivalents.
===is suspect though.- In 5.0,
number < Numberis disallowed - We have a change that makes relational comparison consider
valueOf(Stricter relational comparisons checkingvalueOf#52807) - which re-allowsnumber < Number! - We don't feel like it's a huge problem to error on these - would prefer people not use these types.
- People shouldn't be referencing these anyway - default typescript-eslint rule is
ban-typeswhich stops these.- So not unbreaking
number < Numberin 5.0 - it's too late in the game regardless of what happens in 5.1.
- So not unbreaking
- Aside: probably should not perform these in the relationship checks, should liken these to the
NaNchecks.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Design NotesNotes from our design meetingsNotes from our design meetings