-
The following types/namespaces are now string enums:
ts.ScriptElementKind,ts.HighlightSpanKind,ts.ClassificationTypeNames,protocol.CommandTypes,protocol.IndentStyle,protocol.JsxEmit,protocol.ModuleKind,protocol.ModuleResolutionKind,protocol.NewLineKind, andprotocol.ScriptTarget. Also,ts.CommandNamesis now an alias forprotocol.CommandTypes. -
The type
EnumLiteralTypewas removed andLiteralTypeis used instead.LiteralTypealso replaces.textwith a.valuewhich may be either a number or string. See String valued members in enums. -
Declarationdoes not have anameproperty. TypeScript now recognize assignments in .js files as declarations in certain contexts, e.g.func.prototype.method = function() {..}will be a declaration of membermethodonfunc. As a resultDeclarationis not guaranteed to have anameproperty as before. A new type was introducedNamedDeclarationto take the place ofDeclaration, andDeclarationmoved to be the base type of bothNamedDeclarationandBinaryExpression. Casting toNamedDeclarationshould be safe for non .js declarations. See microsoft/TypeScript#15594 for more details.
ts.Map<T>is now a nativeMap<string, T>or a shim. This affects theSymbolTabletype, exposed bySymbol.members,Symbol.exports, andSymbol.globalExports.
ParseConfigHostnow require a new memberreadFileto support configuration inheritance.
LanguageService.getSourceFileis removed (microsoft/TypeScript#7584),LanguageService.getProgram().getSourceFileshould be used instead.
ts.parseConfigFilehas been renamed tots.parseJsonConfigFileContent
-
return type of
CompilerHost.resolveModuleNameswas changed fromstring[]toResolvedModule[]. Extra optional propertyisExternalLibraryImportin ResolvedModule interface denotes ifProgramshould apply some particular set of policies to the resolved file. For example if Node resolver has resolved non-relative module name to the file in 'node_modules', then this file:- should be a 'd.ts' file
- should be an external module
- should not contain tripleslash references.
Rationale: files containing external typings should not pollute global scope (to avoid conflicts between different versions of the same package). Also such files should never be added to the list of compiled files (otherwise compiled .ts file might overwrite actual .js file with implementation of the package)
TypeChecker.emitFilesis no longer available; useProgram.emitinstead.- Getting diagnostics are now all centralized on Program,
- for Syntactic diagnostics for a single file use:
Program.getSyntacticDiagnostics(sourceFile) - for Syntactic diagnostics for all files use:
Program.getSyntacticDiagnostics() - for Semantic diagnostics for a single file use:
Program.getSemanticDiagnostics(sourceFile) - for Semantic diagnostics for all files use:
Program.getSemanticDiagnostics() - for compiler options and global diagnostics use:
Program.getGlobalDiagnostics()
- for Syntactic diagnostics for a single file use:
Tip: use ts.getPreEmitDiagnostics(program) to get syntactic, semantic, and global diagnostics for all files
Here are the details:
CompilerHost.getDefaultLibFilename=>CompilerHost.getDefaultLibFileNameSourceFile.filename=>SourceFile.fileNameFileReference.filename=>FileReference.fileNameLanguageServiceHost.getDefaultLibFilename=>LanguageServiceHost.getDefaultLibFileNameLanguageServiceShimHost.getDefaultLibFilename=>LanguageServiceShimHost.getDefaultLibFileName
The full list of APIs can be found in this commit
The syntacticClassifierAbsent parameter for the Classifier.getClassificationsForLine is now required
See Pull Request #2051 for more details.
TextChange.start and TextChange.length became properties instead of methods.
SourceFile.getLineAndCharacterFromPosition became SourceFile.getLineAndCharacterOfPosition
We did some cleanup to the public interfaces, here is the full list of changes:
- Commit 2ee134c6b3c0ec
- Commit 35dde28d44122c
- Commit c9ef4db99ac93bb1c166a
- Commit b4e5d5b0b460cc88a10db
The two files exposed helpers in the past that were not part of the supported TypeScript API. If you were using any of these APIs please file an issue to re-expose them; requests for exposing helper APIs will be triaged on a case-per-case basis.
For more information please see the full change.