{"id":10875,"library":"fastcomments-typescript","title":"FastComments TypeScript Types","description":"This package, `fastcomments-typescript`, provides a comprehensive set of TypeScript type definitions for interacting with the FastComments platform. It includes types for API models, such as comment data structures and user profiles, as well as request and response bodies for various API operations (e.g., creating or updating comments). Additionally, it defines types for widget configurations, ensuring type safety when embedding and customizing the FastComments widget within a TypeScript application. The current stable version is 3.0.13. Release cadence typically aligns with updates to the FastComments API and SDK, ensuring type definitions remain consistent with the latest platform features. Its key differentiator is providing official, precise type guidance for developers integrating with FastComments, minimizing runtime errors related to data shape mismatches.","status":"active","version":"3.0.13","language":"javascript","source_language":"en","source_url":"https://github.com/fastcomments/fastcomments-typescript","tags":["javascript","typescript"],"install":[{"cmd":"npm install fastcomments-typescript","lang":"bash","label":"npm"},{"cmd":"yarn add fastcomments-typescript","lang":"bash","label":"yarn"},{"cmd":"pnpm add fastcomments-typescript","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Use 'import type' for type-only imports to ensure they are erased at compile-time and prevent accidental runtime dependency.","wrong":"import { Comment } from 'fastcomments-typescript';","symbol":"Comment","correct":"import type { Comment } from 'fastcomments-typescript';"},{"note":"Most API model types are named exports. The package ships ESM-only type definitions.","wrong":"import CreateCommentRequest from 'fastcomments-typescript';","symbol":"CreateCommentRequest","correct":"import type { CreateCommentRequest } from 'fastcomments-typescript';"},{"note":"This package is designed for TypeScript environments and ESM consumption. CommonJS 'require' will not correctly resolve type definitions.","wrong":"const WidgetConfig = require('fastcomments-typescript');","symbol":"WidgetConfig","correct":"import type { WidgetConfig } from 'fastcomments-typescript';"}],"quickstart":{"code":"import type { Comment, CreateCommentRequest, WidgetConfig } from 'fastcomments-typescript';\n\n// Example: Defining a comment object received from the API\nconst myComment: Comment = {\n  id: 'some-comment-id-123',\n  userId: 'user-456',\n  text: 'This is an example comment.',\n  createdAt: new Date().toISOString(),\n  author: {\n    id: 'user-456',\n    displayName: 'Example User',\n    profileUrl: 'https://example.com/users/456',\n    avatarURL: 'https://example.com/avatars/456.png'\n  },\n  status: 'APPROVED',\n  threadId: 'blog-post-abc'\n};\n\n// Example: Defining a request payload for creating a new comment\nconst newCommentPayload: CreateCommentRequest = {\n  text: 'A new comment to be posted on the thread.',\n  threadId: 'blog-post-xyz',\n  url: 'https://example.com/blog/post-xyz',\n  // Additional optional fields like parentId, anonymousUser, etc., can be added here\n};\n\n// Example: Defining widget configuration for embedding FastComments\nconst myWidgetConfig: WidgetConfig = {\n  tenantId: 'your-tenant-id-here',\n  url: 'https://example.com/current-page-url',\n  // Many more configuration options are available\n  theme: 'dark',\n  replyingPlaceholderText: 'Write your reply...', \n  maxCommentLength: 1000,\n  disableVoting: false\n};\n\nconsole.log('Defined Comment:', myComment);\nconsole.log('Defined New Comment Payload:', newCommentPayload);\nconsole.log('Defined Widget Configuration:', myWidgetConfig);\n\n// These types provide compile-time safety when interacting with FastComments data and APIs.\nfunction handleIncomingComment(commentData: Comment) {\n  console.log(`Received comment from ${commentData.author.displayName}: ${commentData.text.substring(0, 50)}...`);\n}\n\nhandleIncomingComment(myComment);\n","lang":"typescript","description":"This quickstart demonstrates how to import and use core FastComments types (Comment, CreateCommentRequest, WidgetConfig) to define data structures, enhancing type safety in your application."},"warnings":[{"fix":"Review the FastComments changelog and update your code to align with the new type definitions. Re-running `npm install` or `yarn` may be necessary to ensure you have the latest types.","message":"Major version updates (e.g., v2 to v3) often introduce breaking changes to type definitions, reflecting changes in the FastComments API or underlying data structures. This may require updates to your code to match new property names, types, or required fields.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Do not attempt to import or use anything from this package at runtime. Its purpose is purely for development-time type safety. If you need runtime functionality, use the FastComments JavaScript SDK.","message":"This package provides only TypeScript type definitions; it contains no runtime JavaScript code or functionality. It is solely used for compile-time type checking and will be entirely removed during compilation to plain JavaScript.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Verify `compilerOptions.moduleResolution` is set to 'Node' or 'Bundler' and `compilerOptions.target` is appropriate for your environment in `tsconfig.json`. Ensure `skipLibCheck` is not hiding critical errors.","message":"Ensure your TypeScript project is configured to correctly resolve modules and type declarations. Incorrect `moduleResolution` settings in `tsconfig.json` can lead to 'Cannot find module' errors even if the package is installed.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Run `npm install fastcomments-typescript` or `yarn add fastcomments-typescript`. Check your `tsconfig.json` for appropriate `moduleResolution` and `baseUrl` settings.","cause":"The package is either not installed, not correctly listed in `node_modules`, or TypeScript's `moduleResolution` settings prevent it from being found.","error":"TS2307: Cannot find module 'fastcomments-typescript' or its corresponding type declarations."},{"fix":"Consult the `fastcomments-typescript` type definitions to ensure all required properties are present and their types match the expected structure. The error message usually points to the specific missing or mismatched property.","cause":"An object literal or variable is missing required properties, or has properties with incorrect types, according to the `Comment` (or any other imported) interface/type.","error":"TS2345: Argument of type '{ /* ... */ }' is not assignable to parameter of type 'Comment'. Property 'id' is missing in type '{ /* ... */ }' but required in type 'Comment'."}],"ecosystem":"npm"}