@@ -1736,6 +1736,11 @@ namespace ts {
1736
1736
*/
1737
1737
getTypeChecker ( ) : TypeChecker ;
1738
1738
1739
+ /**
1740
+ * Gets a map of loaded compiler extensions
1741
+ */
1742
+ getCompilerExtensions ( ) : ExtensionCollectionMap ;
1743
+
1739
1744
/* @internal */ getCommonSourceDirectory ( ) : string ;
1740
1745
1741
1746
// For testing purposes only. Should not be used by any other consumers (including the
@@ -1812,6 +1817,7 @@ namespace ts {
1812
1817
getSourceFiles ( ) : SourceFile [ ] ;
1813
1818
getSourceFile ( fileName : string ) : SourceFile ;
1814
1819
getResolvedTypeReferenceDirectives ( ) : Map < ResolvedTypeReferenceDirective > ;
1820
+ getCompilerExtensions ( ) : ExtensionCollectionMap ;
1815
1821
}
1816
1822
1817
1823
export interface TypeChecker {
@@ -2496,13 +2502,14 @@ namespace ts {
2496
2502
length : number ;
2497
2503
messageText : string | DiagnosticMessageChain ;
2498
2504
category : DiagnosticCategory ;
2499
- code : number ;
2505
+ code : number | string ;
2500
2506
}
2501
2507
2502
2508
export enum DiagnosticCategory {
2503
2509
Warning ,
2504
2510
Error ,
2505
2511
Message ,
2512
+ Extension ,
2506
2513
}
2507
2514
2508
2515
export enum ModuleResolutionKind {
@@ -2586,6 +2593,7 @@ namespace ts {
2586
2593
typesSearchPaths ?: string [ ] ;
2587
2594
/*@internal */ version ?: boolean ;
2588
2595
/*@internal */ watch ?: boolean ;
2596
+ extensions ?: string [ ] | Map < any > ;
2589
2597
2590
2598
[ option : string ] : CompilerOptionsValue | undefined ;
2591
2599
}
@@ -2893,6 +2901,57 @@ namespace ts {
2893
2901
failedLookupLocations : string [ ] ;
2894
2902
}
2895
2903
2904
+ export type LintErrorMethod = ( err : string , span : Node ) => void ;
2905
+ export type LintAcceptMethod = ( ) => void ;
2906
+
2907
+ /*
2908
+ * Walkers call accept to decend into the node's children
2909
+ * Walkers call error to add errors to the output.
2910
+ */
2911
+ export interface LintWalker {
2912
+ visit ( node : Node , accept : LintAcceptMethod , error : LintErrorMethod ) : void ;
2913
+ }
2914
+
2915
+ export interface SyntacticLintProviderStatic {
2916
+ new ( typescript : typeof ts , args : any ) : LintWalker ;
2917
+ }
2918
+
2919
+ export interface SemanticLintProviderStatic {
2920
+ new ( typescript : typeof ts , checker : TypeChecker , args : any ) : LintWalker ;
2921
+ }
2922
+
2923
+ export namespace ExtensionKind {
2924
+ export const SemanticLint : "semantic-lint" = "semantic-lint" ;
2925
+ export type SemanticLint = "semantic-lint" ;
2926
+ export const SyntacticLint : "syntactic-lint" = "syntactic-lint" ;
2927
+ export type SyntacticLint = "syntactic-lint" ;
2928
+ }
2929
+ export type ExtensionKind = ExtensionKind . SemanticLint | ExtensionKind . SyntacticLint ;
2930
+
2931
+ export interface ExtensionCollectionMap {
2932
+ "syntactic-lint" ?: SyntacticLintExtension [ ] ;
2933
+ "semantic-lint" ?: SemanticLintExtension [ ] ;
2934
+ [ index : string ] : Extension [ ] | undefined ;
2935
+ }
2936
+
2937
+ export interface ExtensionBase {
2938
+ name : string ;
2939
+ args : any ;
2940
+ kind : ExtensionKind ;
2941
+ }
2942
+
2943
+ // @kind (ExtensionKind.SyntacticLint)
2944
+ export interface SyntacticLintExtension extends ExtensionBase {
2945
+ ctor : SyntacticLintProviderStatic ;
2946
+ }
2947
+
2948
+ // @kind (ExtensionKind.SemanticLint)
2949
+ export interface SemanticLintExtension extends ExtensionBase {
2950
+ ctor : SemanticLintProviderStatic ;
2951
+ }
2952
+
2953
+ export type Extension = SyntacticLintExtension | SemanticLintExtension ;
2954
+
2896
2955
export interface CompilerHost extends ModuleResolutionHost {
2897
2956
getSourceFile ( fileName : string , languageVersion : ScriptTarget , onError ?: ( message : string ) => void ) : SourceFile ;
2898
2957
getSourceFileByPath ?( fileName : string , path : Path , languageVersion : ScriptTarget , onError ?: ( message : string ) => void ) : SourceFile ;
@@ -2919,6 +2978,14 @@ namespace ts {
2919
2978
* This method is a companion for 'resolveModuleNames' and is used to resolve 'types' references to actual type declaration files
2920
2979
*/
2921
2980
resolveTypeReferenceDirectives ?( typeReferenceDirectiveNames : string [ ] , containingFile : string ) : ResolvedTypeReferenceDirective [ ] ;
2981
+
2982
+ /**
2983
+ * Delegates the loading of compiler extensions to the compiler host.
2984
+ * The function should return the result of executing the code of an extension
2985
+ * - its exported members. These members will be searched for objects who have been decorated with
2986
+ * specific flags.
2987
+ */
2988
+ loadExtension ?( extension : string ) : any ;
2922
2989
}
2923
2990
2924
2991
export interface TextSpan {
0 commit comments