GithubHelp home page GithubHelp logo

Comments (12)

cesarvspr avatar cesarvspr commented on June 26, 2024

Will be potentially fixed in #199

from fluent-json-schema.

aboutlo avatar aboutlo commented on June 26, 2024

@cyberwombat can you test it with #199 fixes?

from fluent-json-schema.

cyberwombat avatar cyberwombat commented on June 26, 2024

I think still an issue, additionally it looks like ExtendedSchema is not exported anymore. Heres a screenshot of errors in VSCode with 199.

Screen Shot 2022-10-28 at 8 02 32 AM

What I currently have to do to make it work:

import FJS from 'fluent-json-schema'
export const S = FJS.default 
export const fooSchema =  S.string().maxLength(200)

Here's my tsconfig:

{
  "extends": "@tsconfig/node16/tsconfig.json",
  "compilerOptions": {
    "useUnknownInCatchVariables": false,
    "target": "es2020",
    "lib": ["es2020"],
    "module": "node16",
    "moduleResolution": "NodeNext",
    "esModuleInterop": true, // Eases ESM support
    "types": ["node"],
    "allowSyntheticDefaultImports": true,
    "declaration": true,
    "strict": true,
    "strictNullChecks": true,
    "alwaysStrict": true,
    //importsNotUsedAsValues
    // "noImplicitAny": false,
    "incremental": true,
    "noImplicitReturns": false,
    "noImplicitThis": false,
    "noUnusedLocals": false,
    "noUnusedParameters": false,
    "noEmit": true,
    "noFallthroughCasesInSwitch": false,
    "inlineSourceMap": true,
    "inlineSources": true,
    "experimentalDecorators": true,
    "strictPropertyInitialization": false,
    // "typeRoots": ["./node_modules/@types"]
    "resolveJsonModule": true,
    "outDir": "dist",
    "baseUrl": ".",
    "paths": {
    },
    "typeRoots": ["node_modules/@types", "typings"],
    "skipLibCheck": true,
    "forceConsistentCasingInFileNames": true
  }
}

TS: 4.8.4

from fluent-json-schema.

cesarvspr avatar cesarvspr commented on June 26, 2024

I think still an issue, additionally it looks like ExtendedSchema is not exported anymore. Heres a screenshot of errors in VSCode with 199.

Fixed in the last commit, please check if you find other issues

from fluent-json-schema.

cyberwombat avatar cyberwombat commented on June 26, 2024

That fixed the ExtendedSchema but I am still having original issue with needed to use .default

import S from 'fluent-json-schema'

export const commonLabelSchema = S.default.string()

from fluent-json-schema.

cesarvspr avatar cesarvspr commented on June 26, 2024

@cyberwombat can I see what you are extending @tsconfig/node16/tsconfig.json ?

I was able to use

import S, { FluentSchemaError, ExtendedSchema } from "..";

console.log("isFluentSchema:", S.object().isFluentJSONSchema);
const schema = S.string()

If we find out what is happening would be nice to reproduce inside the FluentJSONSchema.test-d.ts

from fluent-json-schema.

cyberwombat avatar cyberwombat commented on June 26, 2024

@cesarvspr @tsconfig/node16/tsconfig.json extend is not necessary. I can remove it with same issue. What is your tsconfig?

from fluent-json-schema.

cesarvspr avatar cesarvspr commented on June 26, 2024

@cyberwombat

I was able to use you provided tsconfig.json file and my own which is

{
  "compilerOptions": {
    "useUnknownInCatchVariables": false,
    "target": "es2020",
    "lib": ["es2020"],
    "module": "node16",
    "moduleResolution": "NodeNext",
  }
}

here you can see my test:
minimal_project.zip

from fluent-json-schema.

cyberwombat avatar cyberwombat commented on June 26, 2024

You need "type":"module" in package.json as well for ESM. It fails then.

from fluent-json-schema.

cesarvspr avatar cesarvspr commented on June 26, 2024

you are right @cyberwombat, but I could not find a solution for this specific case yet.

Btw, why are you using the "type":"module"?

from fluent-json-schema.

cyberwombat avatar cyberwombat commented on June 26, 2024

I am migrating to 100% esm and that's part of the jump. If I don't then my code stays CJS when imported. I don't know of a solution except to build as both esm and cjs and using the exporrts field in package.json od doing the full esm jump as many packages are doing. I heard there is a wrapper out there that can be used to help male the transition but I think it still requires a build output though I am not sure. Maybe this helps https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c

from fluent-json-schema.

cesarvspr avatar cesarvspr commented on June 26, 2024

@climba03003 Would you please help with this? I have a PR ready that just needs to work when we have "type":"module" on the package.json

from fluent-json-schema.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.