@@ -1728,6 +1728,11 @@ namespace ts {
1728
1728
*/
1729
1729
getTypeChecker ( ) : TypeChecker ;
1730
1730
1731
+ /**
1732
+ * Gets a map of loaded compiler extensions
1733
+ */
1734
+ getCompilerExtensions ( ) : ExtensionCollectionMap ;
1735
+
1731
1736
/* @internal */ getCommonSourceDirectory ( ) : string ;
1732
1737
1733
1738
// For testing purposes only. Should not be used by any other consumers (including the
@@ -1804,6 +1809,7 @@ namespace ts {
1804
1809
getSourceFiles ( ) : SourceFile [ ] ;
1805
1810
getSourceFile ( fileName : string ) : SourceFile ;
1806
1811
getResolvedTypeReferenceDirectives ( ) : Map < ResolvedTypeReferenceDirective > ;
1812
+ getCompilerExtensions ( ) : ExtensionCollectionMap ;
1807
1813
}
1808
1814
1809
1815
export interface TypeChecker {
@@ -2488,13 +2494,14 @@ namespace ts {
2488
2494
length : number ;
2489
2495
messageText : string | DiagnosticMessageChain ;
2490
2496
category : DiagnosticCategory ;
2491
- code : number ;
2497
+ code : number | string ;
2492
2498
}
2493
2499
2494
2500
export enum DiagnosticCategory {
2495
2501
Warning ,
2496
2502
Error ,
2497
2503
Message ,
2504
+ Extension ,
2498
2505
}
2499
2506
2500
2507
export enum ModuleResolutionKind {
@@ -2578,6 +2585,7 @@ namespace ts {
2578
2585
typesSearchPaths ?: string [ ] ;
2579
2586
/*@internal */ version ?: boolean ;
2580
2587
/*@internal */ watch ?: boolean ;
2588
+ extensions ?: string [ ] | Map < any > ;
2581
2589
2582
2590
[ option : string ] : CompilerOptionsValue | undefined ;
2583
2591
}
@@ -2874,6 +2882,57 @@ namespace ts {
2874
2882
failedLookupLocations : string [ ] ;
2875
2883
}
2876
2884
2885
+ export type LintErrorMethod = ( err : string , span : Node ) => void ;
2886
+ export type LintAcceptMethod = ( ) => void ;
2887
+
2888
+ /*
2889
+ * Walkers call accept to decend into the node's children
2890
+ * Walkers call error to add errors to the output.
2891
+ */
2892
+ export interface LintWalker {
2893
+ visit ( node : Node , accept : LintAcceptMethod , error : LintErrorMethod ) : void ;
2894
+ }
2895
+
2896
+ export interface SyntacticLintProviderStatic {
2897
+ new ( typescript : typeof ts , args : any ) : LintWalker ;
2898
+ }
2899
+
2900
+ export interface SemanticLintProviderStatic {
2901
+ new ( typescript : typeof ts , checker : TypeChecker , args : any ) : LintWalker ;
2902
+ }
2903
+
2904
+ export namespace ExtensionKind {
2905
+ export const SemanticLint : "semantic-lint" = "semantic-lint" ;
2906
+ export type SemanticLint = "semantic-lint" ;
2907
+ export const SyntacticLint : "syntactic-lint" = "syntactic-lint" ;
2908
+ export type SyntacticLint = "syntactic-lint" ;
2909
+ }
2910
+ export type ExtensionKind = ExtensionKind . SemanticLint | ExtensionKind . SyntacticLint ;
2911
+
2912
+ export interface ExtensionCollectionMap {
2913
+ "syntactic-lint" ?: SyntacticLintExtension [ ] ;
2914
+ "semantic-lint" ?: SemanticLintExtension [ ] ;
2915
+ [ index : string ] : Extension [ ] | undefined ;
2916
+ }
2917
+
2918
+ export interface ExtensionBase {
2919
+ name : string ;
2920
+ args : any ;
2921
+ kind : ExtensionKind ;
2922
+ }
2923
+
2924
+ // @kind (ExtensionKind.SyntacticLint)
2925
+ export interface SyntacticLintExtension extends ExtensionBase {
2926
+ ctor : SyntacticLintProviderStatic ;
2927
+ }
2928
+
2929
+ // @kind (ExtensionKind.SemanticLint)
2930
+ export interface SemanticLintExtension extends ExtensionBase {
2931
+ ctor : SemanticLintProviderStatic ;
2932
+ }
2933
+
2934
+ export type Extension = SyntacticLintExtension | SemanticLintExtension ;
2935
+
2877
2936
export interface CompilerHost extends ModuleResolutionHost {
2878
2937
getSourceFile ( fileName : string , languageVersion : ScriptTarget , onError ?: ( message : string ) => void ) : SourceFile ;
2879
2938
getSourceFileByPath ?( fileName : string , path : Path , languageVersion : ScriptTarget , onError ?: ( message : string ) => void ) : SourceFile ;
@@ -2900,6 +2959,14 @@ namespace ts {
2900
2959
* This method is a companion for 'resolveModuleNames' and is used to resolve 'types' references to actual type declaration files
2901
2960
*/
2902
2961
resolveTypeReferenceDirectives ?( typeReferenceDirectiveNames : string [ ] , containingFile : string ) : ResolvedTypeReferenceDirective [ ] ;
2962
+
2963
+ /**
2964
+ * Delegates the loading of compiler extensions to the compiler host.
2965
+ * The function should return the result of executing the code of an extension
2966
+ * - its exported members. These members will be searched for objects who have been decorated with
2967
+ * specific flags.
2968
+ */
2969
+ loadExtension ?( extension : string ) : any ;
2903
2970
}
2904
2971
2905
2972
export interface TextSpan {
0 commit comments