ts-api-utils - v3.0.0-rc.1
    Preparing search index...

    Function isCompilerOptionEnabled

    • Checks if a given compiler option is enabled. It handles dependencies of options, e.g. declaration is implicitly enabled by composite or strictNullChecks is enabled by strict. However, it does not check dependencies that are already checked and reported as errors, e.g. checkJs without allowJs. This function only handles boolean flags.

      Parameters

      • options: CompilerOptions
      • option:
            | "allowImportingTsExtensions"
            | "allowJs"
            | "allowArbitraryExtensions"
            | "allowSyntheticDefaultImports"
            | "allowUmdGlobalAccess"
            | "allowUnreachableCode"
            | "allowUnusedLabels"
            | "alwaysStrict"
            | "checkJs"
            | "declaration"
            | "declarationMap"
            | "emitDeclarationOnly"
            | "disableSizeLimit"
            | "disableSourceOfProjectReferenceRedirect"
            | "disableSolutionSearching"
            | "disableReferencedProjectLoad"
            | "downlevelIteration"
            | "emitBOM"
            | "emitDecoratorMetadata"
            | "exactOptionalPropertyTypes"
            | "experimentalDecorators"
            | "forceConsistentCasingInFileNames"
            | "importHelpers"
            | "inlineSourceMap"
            | "inlineSources"
            | "isolatedModules"
            | "isolatedDeclarations"
            | "keyofStringsOnly"
            | "libReplacement"
            | "noEmit"
            | "noCheck"
            | "noEmitHelpers"
            | "noEmitOnError"
            | "noErrorTruncation"
            | "noFallthroughCasesInSwitch"
            | "noImplicitAny"
            | "noImplicitReturns"
            | "noImplicitThis"
            | "noStrictGenericChecks"
            | "noUnusedLocals"
            | "noUnusedParameters"
            | "noImplicitUseStrict"
            | "noPropertyAccessFromIndexSignature"
            | "assumeChangesOnlyAffectDirectDependencies"
            | "noLib"
            | "noResolve"
            | "noUncheckedIndexedAccess"
            | "preserveConstEnums"
            | "noImplicitOverride"
            | "preserveSymlinks"
            | "preserveValueImports"
            | "composite"
            | "incremental"
            | "removeComments"
            | "resolvePackageJsonExports"
            | "resolvePackageJsonImports"
            | "rewriteRelativeImportExtensions"
            | "skipLibCheck"
            | "skipDefaultLibCheck"
            | "sourceMap"
            | "strict"
            | "strictFunctionTypes"
            | "strictBindCallApply"
            | "strictNullChecks"
            | "strictPropertyInitialization"
            | "strictBuiltinIteratorReturn"
            | "stripInternal"
            | "suppressExcessPropertyErrors"
            | "suppressImplicitAnyIndexErrors"
            | "traceResolution"
            | "useUnknownInCatchVariables"
            | "noUncheckedSideEffectImports"
            | "resolveJsonModule"
            | "verbatimModuleSyntax"
            | "erasableSyntaxOnly"
            | "esModuleInterop"
            | "useDefineForClassFields"

      Returns boolean

      const options = {
      allowJs: true,
      };

      isCompilerOptionEnabled(options, "allowJs"); // true
      isCompilerOptionEnabled(options, "allowSyntheticDefaultImports"); // false